home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-04 | 1.8 KB | 77 lines | [TEXT/KAHL] |
- /********************************************************* DEFINITION
- DATE: 9/28/93
- AUTHOR: Eric R. Rosé
-
- CLASS: CPPDialogIntText
-
- SUPERCLASS: CPPDialogText
-
- This C++ class manages a textedit area with no scrollbars and
- only accepts numbers up to 255 characters.
-
- ********************************************************************/
-
- #include <CPPIntText.h>
-
- /*-----------------------------------------------------------------*/
- /*------------------------ PUBLIC METHODS -------------------------*/
- /*-----------------------------------------------------------------*/
-
- CPPIntText::CPPIntText (CPPWindow *OurWindow,
- Rect *itsBounds,
- int defaultValue,
- int maxLength,
- int Font,
- int FSize) :
- CPPDialogText (OurWindow, itsBounds, (StringPtr)NULL,
- maxLength, Font, FSize)
- {
- SetFilterKind (number); // only numbers are allowed
- SetFilterSense (pass);
- SetFilterString (NULL);
-
- SetToInt(defaultValue);
- }
-
- /*-----------------------------------------------------------------*/
-
- CPPIntText::~CPPIntText (void)
- {
- }
-
- /*-----------------------------------------------------------------*/
-
- char *CPPIntText::ClassName (void)
- {
- return "CPPDialogIntText";
- }
-
- /*-----------------------------------------------------------------*/
-
- int CPPIntText::GetAsInt (void)
- /* Convert the contents of the TEArea into an integer and return it */
- {
- StringPtr STemp = GetAsString();
- long tempLInt;
-
- if (STemp)
- {
- StringToNum(STemp, &tempLInt);
- return tempLInt;
- }
- else
- return 0;
- }
-
-
- /*-----------------------------------------------------------------*/
-
- void CPPIntText::SetToInt (int newValue)
- /* set the text object to contain the passed in integer value */
- {
- Str255 STemp;
-
- NumToString (newValue, STemp);
- SetToString (STemp);
- }
-